<?php
    require_once ('config.php');

session_start();

/*$strLanguage = (isset($_GET['langue']) ? $_GET['langue']: 'fr');
if($strLanguage == 'en'){
    require_once ('english.php');
}else{
    require_once ('french.php');
}*/

function tep_db_error($query, $errno, $error) { 
    die('<font color="#000000"><b>' . $errno . ' - ' . $error . '<br><br>' . $query . '<br><br><small><font color="#ff0000">[TEP STOP]</font></small><br><br></b></font>');
  }  
function tep_db_checkDb(){
    $link = mysql_connect(DATABASE_SERVER,DATABASE_USERNAME,DATABASE_PASSWORD);

    if(!$link){
        return false;
    }
    #echo('Connection OK.<br/>');
    $db = mysql_select_db(DATABASE_NAME);
    if(!$db){
        return false;
    }
    return true;
}

function tep_db_query($query){

    mysql_query("set names 'utf8'");
    $result = mysql_query($query) or tep_db_error($query, mysql_errno(), mysql_error());
    return $result;
}

function tep_db_insert_id() {
    return mysql_insert_id();
}
  
  function tep_db_fetch_array($db_query) {
    return mysql_fetch_array($db_query, MYSQL_ASSOC);
  }

function tep_db_close($link = 'db_link'){
    global $$link;
    return mysql_close($$link);
}

#handle for langue params
/*function tep_embed_langue_url($url){
    $strLanguage = (isset($_GET['langue']) ? $_GET['langue']: 'fr');
    //if(strlen($_SERVER['QUERY_STRING'])==0){
//        $url .= "?langue=".$strLanguage;
//        echo "url embed 0".$url;
//    }else{
        if((strpos($url, 'langue=')=== false)&&(strpos($url, '?')=== false)){
            $url .= "?langue=".$strLanguage;   
        }else if(strpos($url, 'langue=')!== false){
            $url .= "&langue=".$strLanguage;
        }else if(strpos($url, '?')!== false){
            $url .= "&langue=".$strLanguage;          
        }
    //}
    return $url;
}
function tep_redirect($url){
  //  echo tep_embed_langue_url($url);
    #redirect to url page
    //echo "url ".tep_embed_langue_url($url);
    header("Location: ".tep_embed_langue_url($url));
   //echo "<script type=\"text/javascript\">window.location='$url';</script>";
    exit;
}

function tep_send_mail($sendName, $friend, $to, $subject='', $message='', $productlink,$strLanguage){    
    
        if($strLanguage=='en'){
            if(strlen($subject)== 0)
                $subject='Your friend wants to send you an email about this product';
    
            if(strlen($message)==0){
                $message  = "Hello ".$sendName.",\r\n\r\nYour friend ";
                $message .= $friend.", participated in our Valentine's Day quiz and hopes that you will give her the gift \r\non the following link $productlink \r\n 
				\r\nYou're sure to please her! \r\n\r\nWelcome to our online boutique: www.tintamar.com \r\n ";
				$message = utf8_decode($message) ;
            }    
        }else{
            if(strlen($subject)== 0)
                $subject='Votre ami veut vous envoyer un e-mail sur ce produit';
    
            if(strlen($message)==0){
                $message  = "Bonjour ".$sendName.", \r\n\r\n";
                $message .= $friend.", votre ami(e) a participé à notre Quiz St Valentin et rêve que vous lui offriez \r\nle produit $productlink \r\n" 
                    ."Vous êtes certain de lui faire plaisir ! \r\n \r\nBienvenue sur notre boutique en ligne www.tintamar.com \r\n ";
				$message = utf8_decode($message) ;
				

            }
        }

    # Additional headers    
    # $headers = 'From: Tintamar' . "\r\n";  
	$headers = 'From: island@tintamar.com' . "\r\n"; 
 		

    #send mail
    return mail($to,$subject, $message, $headers);        
}

function tep_encode_specialchars($url){
    return htmlspecialchars($url, ENT_QUOTES);
}*/
?>